package com.zhiyou.check.controller;

import com.zhiyou.check.pojo.Rest;
import com.zhiyou.check.service.RestService;
import com.zhiyou.common.pojo.Result;
import com.zhiyou.common.pojo.StateCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@org.springframework.web.bind.annotation.RestController
@RequestMapping("/rest")
public class RestController {

    @Autowired
    RestService restService;
    @GetMapping("/findByTid/{tid}/{rState}/{rType}")
    public Result findByTidAndByRState(@PathVariable Integer tid,@PathVariable Integer rState, @PathVariable Integer rType){
        return new Result(true, StateCode.OK,"查询成功",restService.findByTidAndByRState(tid,rState,rType));
    }

    @GetMapping("/findBySid/{sid}/{rState}/{rType}")
    public Result findBySidAndByRState(@PathVariable Integer sid,@PathVariable Integer rState, @PathVariable Integer rType){
        return new Result(true, StateCode.OK,"查询成功",restService.findByTidAndByRState(sid,rState,rType));
    }
    //
    @PostMapping("/update")
    public Result updateRState(Rest rest){
        restService.updateRState(rest);
        return new Result(true, StateCode.OK,"修改成功");
    }

    @PostMapping("/insert")
    public Result insertRest(Rest rest){
        restService.insertRest(rest);
        return new Result(true, StateCode.OK,"添加成功");
    }



}
